package com.bysj.sausys.common;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 用户常量类
 *
 * @author WangZK
 */
public class UserConst {

    /**
     * session中存储用户的key
     */
    public static final String CURRENT_USER = "currentUser";
    /**
     * session中存储用户类型的key
     */
    public static final String CATEGORY_ID = "categoryId";
    /**
     * session中存储所属社团ID的key
     */
    public static final String ASS_ID = "assId";

    /**
     * 用户类型
     */
    public static final String CHAOJIGUANLIYUAN = "chaojiguanliyuan";
    public static final String TUANWEIGUANLIYUAN = "tuanweiguanliyuan";
    public static final String SHELIANGUANLIYUAN = "shelianguanliyuan";
    public static final String SHETUANGUANLIYUAN = "shetuanguanliyuan";

    /**
     * 用户状态：启用
     */
    public static final int ENABLE = 1;
    /**
     * 用户状态：禁用
     */
    public static final int DISABLE = 0;

    /**
     * 获取系统当前用户
     *
     * @param request
     * @return
     */
    public static Map getCurrentUser(HttpServletRequest request) {
        return (Map) request.getSession().getAttribute(UserConst.CURRENT_USER);
    }

    /**
     * 获取当前用户名
     *
     * @param map
     * @return
     */
    public static String getCurrentUsername(Map map) {
        return (String) map.get("username");
    }

    /**
     * 获取当前用户的用户类型
     *
     * @param map
     * @return
     */
    public static String getCurrentUserCategory(Map map) {
        return (String) map.get(UserConst.CATEGORY_ID);
    }

    /**
     * 获取当前用户所属社团
     *
     * @param map
     * @return
     */
    public static Integer getCurrentAssId(Map map) {
        return (Integer) map.get(UserConst.ASS_ID);
    }
}
